import { request } from './request'
import type { Banner, PaginatedResponse } from '@/types'

// 获取Banner列表
export const getBanners = (params: { page: number; page_size: number; status?: number }) => {
  return request<PaginatedResponse<Banner>>({
    url: '/admin/banners',
    method: 'get',
    params
  })
}

// 获取Banner详情
export const getBanner = (id: number) => {
  return request<Banner>({
    url: `/admin/banners/${id}`,
    method: 'get'
  })
}

// 创建Banner
export const createBanner = (data: Partial<Banner>) => {
  return request<Banner>({
    url: '/admin/banners',
    method: 'post',
    data
  })
}

// 更新Banner
export const updateBanner = (id: number, data: Partial<Banner>) => {
  return request<Banner>({
    url: `/admin/banners/${id}`,
    method: 'put',
    data
  })
}

// 删除Banner
export const deleteBanner = (id: number) => {
  return request({
    url: `/admin/banners/${id}`,
    method: 'delete'
  })
}

